<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">


<head th:replace="common/header::common_head"></head>
<title>商品管理</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
<style>

</style>
<!-- DataTables -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="../../bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
<link href="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.css" rel="stylesheet">
<link href="https://unpkg.com/bootstrap-table@1.15.2/dist/extensions/fixed-columns/bootstrap-table-fixed-columns.css"
      rel="stylesheet">
<style type="text/css">
    .shadow {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
        z-index: 998;
        background-color: gainsboro;
        opacity: 0.6;
        display: none;
    }

    #addGoods {
        position: fixed;
        z-index: 999;
        display: none;
        top: 5%;
        left: 40%;

    }

    #editGoods {
        position: fixed;
        z-index: 999;
        display: none;
        top: 5%;
        left: 40%;

    }

    td {
        height: 50px;
    }
</style>
<head>
    <title>弹出层</title>
    <meta charset="utf-8">
    <style>
        .black_overlay {
            display: none;
            position: absolute;
            top: 0%;
            left: 0%;
            width: 100%;
            height: 100%;
            background-color: black;
            z-index: 1001;
            -moz-opacity: 0.8;
            opacity: .80;
            filter: alpha(opacity=80);
        }

        .white_content {
            display: none;
            position: absolute;
            top: 10%;
            left: 20%;
            width: 60%;
            height: 80%;
            border: 16px solid lightblue;
            background-color: white;
            z-index: 1002;
            overflow: auto;
        }

        .white_content_small {
            display: none;
            position: absolute;
            top: 20%;
            left: 30%;
            width: 40%;
            height: 50%;
            border: 16px solid lightblue;
            background-color: white;
            z-index: 1002;
            overflow: auto;
        }
    </style>
    <script type="text/javascript">
        //弹出隐藏层
        function ShowDiv(show_div, bg_div) {
            document.getElementById(show_div).style.display = 'block';
            document.getElementById(bg_div).style.display = 'block';
            var bgdiv = document.getElementById(bg_div);
            bgdiv.style.width = document.body.scrollWidth;  // bgdiv.style.height = $(document).height();

            $("#" + bg_div).height($(document).height());
        };

        //关闭弹出层
        function CloseDiv(show_div, bg_div) {
            document.getElementById(show_div).style.display = 'none';
            document.getElementById(bg_div).style.display = 'none';
        };
    </script>
</head>
<style type="text/css">

    .combo {
        border-color: black;
        background-color: #fff;
        border-width: 1px;
        border-style: solid;
        overflow: hidden;
        margin: 0;
        padding: 0;

        display: inline-block;
        white-space: nowrap;
        vertical-align: middle;
    }

    .combo .combo-text {
        font-size: 12px;
        border: 0px;
        line-height: 20px;
        height: 20px;
        margin: 0;
        padding: 0px 2px;
        vertical-align: baseline;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <div th:replace="common/LeftCommon::common_top_left"></div>
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                商品管理
                <small>CommodityManagement</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="/index"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li><a href="#">商品设置</a></li>
                <li class="active">商品管理</li>
            </ol>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <p style="margin: 15px"><b>商品名称：</b> <input id="findGoods"> &nbsp;&nbsp;<button
                                    class="btn btn-info " onclick="searchForName();">&nbsp;&nbsp;查询&nbsp;&nbsp;
                            </button>
                                <button class="btn btn-info" style="margin-left: 35px"><a style="color: #ffffff"
                                                                                          href="/setting/commodity_management">全部商品</a>
                                </button>
                                <button class="btn btn-info" style="float: right;" onclick="ShowDiv('MyDiv','fade')">
                                    ＋新增商品
                                </button>
                            </p>
                        </div>
                        <hr style=" height:2px;border:none;border-top:2px dotted #575757;">
                        <div class="box-body" style="display:none;" id="pcPage">
                            <!-- /.box-header -->

                            <div class="toolbar form-inline">
                                <span>固定行数: </span>
                                <input class="form-control" id="fixedNumber" type="number" value="4" min="1" max="5">
                            </div>
                            <table class="table" id="example2" data-height="700"
                                   style="float: left;overflow: auto; width: 2000px; " data-show-columns="true">
                                <thead>
                                <tr>
                                    <th style="text-align: center;">操作</th>
                                    <th style="text-align: center;">名称</th>
                                    <th style="text-align: center;">货号</th>
                                    <th style="text-align: center;">条码</th>
                                    <th style="text-align: center;">图片</th>
                                    <th style="text-align: center;">品牌</th>
                                    <th style="text-align: center;">分类</th>
                                    <th style="text-align: center;">单位</th>
                                    <th style="text-align: center;">颜色</th>
                                    <th style="text-align: center;">尺码</th>
                                    <th style="text-align: center;">性别</th>
                                    <th style="text-align: center;">包装数</th>
                                    <th style="text-align: center;">采购价</th>
                                    <th style="text-align: center;">批发价</th>
                                    <th style="text-align: center;">零售价</th>
                                    <th style="text-align: center;">建议零售价</th>
                                    <th style="text-align: center;">款式</th>
                                    <th style="text-align: center;">材质</th>
                                    <th style="text-align: center;">季节</th>
                                    <th style="text-align: center;">库存最低预警</th>
                                    <th style="text-align: center;">库存最高预警</th>
                                    <th style="text-align: center;">备注</th>
                                    <th style="text-align: center;">排序</th>
                                    <th style="text-align: center;">状态</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="goods, goodsStat: ${goods}">
                                    <th><a href="javascript:void(0)"
                                           th:onclick="javascript:deleteGoods([[${goods.name}]])">删除</a>
                                        <a href="javascript:void(0)"
                                           th:onclick="javascript:editGoodsDiv([[${goods.id}]],[[${goods.name}]],[[${goods.sort}]]);">修改</a>
                                    </th>
                                    <td th:text="${goods.name}"></td>
                                    <td th:text="${goods.goodsNumber}"></td>
                                    <td th:text="${goods.barCode}"></td>
                                    <td th:text="${goods.imgUrl}"></td>
                                    <td th:text="${goods.brand}"></td>
                                    <td th:text="${goods.classify}"></td>
                                    <td th:text="${goods.unit}"></td>
                                    <td th:text="${goods.color}"></td>
                                    <td th:text="${goods.size}"></td>
                                    <td th:text="${goods.gender}"></td>
                                    <td th:text="${goods.backingPag}"></td>
                                    <td th:text="${goods.purchasePrice}"></td>
                                    <td th:text="${goods.wholesalePrice}"></td>
                                    <td th:text="${goods.salePrice}"></td>
                                    <td th:text="${goods.recommendPrice}"></td>
                                    <td th:text="${goods.style}"></td>
                                    <td th:text="${goods.material}"></td>
                                    <td th:text="${goods.season}"></td>
                                    <td th:text="${goods.stockMin}"></td>
                                    <td th:text="${goods.stockMax}"></td>
                                    <td th:text="${goods.remark}"></td>
                                    <td th:text="${goods.sort}"></td>
                                    <td th:text="${goods.status}"></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="box-body" style="display:none;" id="mobile">
                            <!-- /.box-header -->
                            <table class="table"  style="float: left;overflow: auto; width: 100%; "
                                   data-show-columns="true">
                                <tbody>
                                <tr th:each="goods, goodsStat: ${goods}">
                                    <td>
                                        <ul class="products-list product-list-in-box">
                                            <li class="item">
                                                <div class="product-img">
                                                    <img src="../../dist/img/user1-128x128.jpg" alt="Product Image">
                                                </div>
                                                <div class="product-info">
                                                    <a href="javascript:void(0)" class="product-title">
                                                        <p th:text="${goods.name}" style="position:relative; margin-top:2px;font-size:4.375vw;"></p>
                                                    </a>
                                                    <p style="position: relative;margin-top: -10px" th:text="'(' + ${goods.goodsNumber} + ')'"></p>
                                                    <span class="label label-warning pull-right" style="position:absolute; margin-top:-45px;margin-left: 50% ">
                                                        <a style="color: white" href="javascript:void(0)"
                                                           th:onclick="javascript:editGoodsDiv([[${goods.id}]],[[${goods.name}]],[[${goods.sort}]]);">修改</a>
                                                    </span>
                                                    <span class="label label-warning pull-right"
                                                          style="position:relative; margin-top:-45px;margin-left: 30% ">
                                                    <a style="color: white" href="javascript:void(0)"
                                                       th:onclick="javascript:deleteGoods([[${goods.name}]])">删除</a>
                                                </span>
                                                    <span>
                                                    <p style="position: relative;padding-left: 0px;font-family:宋体;color:black"
                                                       th:text="${goods.barCode}"></p>
                                                    <p style="position: relative;padding-left: 20px;margin-top: -10px;font-family:宋体;color:rgba(0, 0, 0, 0.3)">条码</p>
                                                    <p style="position: absolute;padding-left: 125px;margin-top: -50px;font-family:宋体;color:black" th:if="${goods.brand eq null}">无牌</p>
                                                    <p style="position: absolute;padding-left: 125px;margin-top: -50px;font-family:宋体;color:black"
                                                       th:if="${goods.brand}" th:text="${goods.brand}"></p>
                                                    <p style="position: absolute;padding-left: 125px;margin-top:-30px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">品牌</p>
                                                    <p style="position: absolute;padding-left: 185px;margin-top: -50px;font-family:宋体;color:black"
                                                       th:if="${goods.classify eq null}">无类</p>
                                                    <p style="position: absolute;padding-left: 185px;margin-top: -50px;font-family:宋体;color:black"
                                                       th:if="${goods.classify}" th:text="${goods.classify}"></p>
                                                    <p style="position: absolute;padding-left: 185px;margin-top:-30px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">分类</p>
                                                    <p style="position: relative;padding-left: 0px;padding-top: -10px;font-family:宋体;color:black;"
                                                       th:if="${goods.color eq null}">无色</p>
                                                    <p style="position: relative;padding-left: 0px;padding-top: 45px;font-family:宋体;color:black"
                                                       th:if="${goods.color}" th:text="${goods.color}"></p>
                                                    <p style="position: relative;padding-left: 2px;top:-10px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">颜色</p>
                                                    <p style="position: relative;padding-left: 80px;margin-top: -61px;font-family:宋体;color:black"
                                                       th:text="${goods.size}"></p>
                                                    <p style="position: absolute;padding-left: 80px;margin-top:-10px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">尺码</p>
                                                    <p style="position: absolute;padding-left: 130px;margin-top: -30px;font-family:宋体;color:black"
                                                       th:text="${goods.gender}"></p>
                                                    <p style="position: absolute;padding-left: 130px;margin-top:-10px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">性别</p>
                                                    <p style="position: absolute;padding-left: 195px;margin-top: -30px;font-family:宋体;color:black"
                                                       th:text="${goods.purchasePrice} + ￥"></p>
                                                    <p style="position: absolute;padding-left: 195px;margin-top:-10px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">采购价</p>
                                                    <p style="position: relative;padding-left: 0px;padding-top: 20px;font-family:宋体;color:black"
                                                       th:text="${goods.salePrice} + ￥"></p>
                                                    <p style="position: relative;padding-left: 0px;margin-top:-10px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">零售价</p>
                                                    <p style="position: absolute;padding-left: 70px;margin-top: -50px;font-family:宋体;color:black"
                                                       th:if="${goods.style} eq null">无款式</p>
                                                    <p style="position: absolute;padding-left: 75px;margin-top: -50px;font-family:宋体;color:black"
                                                       th:if="${goods.style}" th:text="${goods.style}"></p>
                                                    <p style="position: absolute;padding-left: 70px;margin-top:-30px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">款式</p>
                                                    <p style="position: absolute;padding-left: 150px;margin-top: -50px;font-family:宋体;color:black"
                                                       th:if="${goods.season} eq null">无季节</p>
                                                    <p style="position: absolute;padding-left: 150px;margin-top: -50px;font-family:宋体;color:black"
                                                       th:if="${goods.season}" th:text="${goods.season}"></p>
                                                    <p style="position: absolute;padding-left: 150px;margin-top:-30px ;font-family:宋体;color:rgba(0, 0, 0, 0.3)">季节</p>
                                                </span>
                                                </div>
                                            </li>
                                        </ul>


                                    </td>

                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <div class="shadow"></div>

            <div id="editGoods" class="white_content" style="width:50%;top:100px">
                <div class="row">
                    <div class="col-xs-12">
                        <div style="height: 40px; background: #0b97c4; text-align: center"><p style="font-size: larger">
                            <b>编辑商品</b></p></div>
                        <form style="background: white" method="post">
                            <table class="table table-condensed post_table  " width="100%">
                                <tr>
                                    <th class="td_right"><span class="text-danger">* </span>商品名称：</th>
                                    <th>
                                        <div class="validate_input">
                                            <input type="text" maxlength="30" name="name" placeholder="商品名称" id="ename">
                                        </div>
                                    </th>
                                    <th class="td_right" style="width:100px">
                                        <nobr><span class="text-danger">* </span>商品货号：</nobr>
                                    </th>
                                    <th>
                                        <div class="validate_input">
                                            <input type="text" id="egoodsNumber" maxlength="128" name="goodsNumber"
                                                   placeholder="商品货号"> <br>
                                        </div>
                                    </th>
                                </tr>
                                <tr>
                                    <td class="td_right"><span class="text-danger">* </span>采购价：</td>
                                    <td>
                                        <div class=" validate_input">
                                            <input type="text" name="purchasePrice" id="epurchasePrice">
                                            <div class="error_container ng-hide">
                                                <div class="error_tip">
                                                    <div class="error_led"><span></span></div>
                                                    <font class="ng-hide">必填，单价不可超过1000 000.</font>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="td_right"><span class="text-danger">* </span>批发价：</td>
                                    <td>
                                        <div class="validate_input">
                                            <input type="text" name="wholesalePrice" id="ewholesalePrice">

                                            <div class="error_container ng-hide">
                                                <div class="error_tip">
                                                    <div class="error_led"><span></span></div>
                                                    <font class="ng-hide">必填，单价不可超过1000 000.</font>
                                                </div>
                                            </div>

                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right">建议零售价：</td>
                                    <td>
                                        <div class="validate_input">
                                            <input type="text" name="recommendPrice" id="erecommendPrice">

                                            <div class="error_container ng-hide">
                                                <div class="error_tip">
                                                    <div class="error_led"><span></span></div>
                                                    <font class="ng-hide">必填，单价不可超过1000 000.</font>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="td_right"><span class="text-danger">* </span>零售价：</td>
                                    <td>
                                        <div class="validate_input" style="display:inline-block;">
                                            <input type="text" name="salePrice" id="esalePrice">
                                            <div class="error_container ng-hide">
                                                <div class="error_tip">
                                                    <div class="error_led"><span></span></div>
                                                    <font class="ng-hide">必填，单价不可超过1000 000.</font>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right"><span class="text-danger">* </span>商品颜色：</td>
                                    <td colspan="3">
                                        <div class=" validate_input">
                                            <input type="text" name="ecolor" id="ecolor">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right"><span class="text-danger">* </span>商品尺码：</td>
                                    <td colspan="3">
                                        <div class=" validate_input">
                                            <input type="text" name="size" id="esize">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right">包装数：</td>
                                    <td>
                                        <div class="validate_input ">
                                            <input style="width: 64px" type="number" min="1" max="100" name="backingPag"
                                                   placeholder="包装数" id="ebackingPag" required>
                                        </div>
                                    </td>
                                    <td>
                                        <div style="float:right;display:inline;">
                                            <p class="right-side">低预警</p>
                                            <div class="validate_input" style="display:inline;">
                                                <input type="number" name="stockMin" id="estockMin" max="100000" min="0"
                                                       style="text-align: center; width: 70px">
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div style="float:right;display:inline;">
                                            <div class="validate_input" style="display:inline;">

                                                <p class="right-side">高预警</p>
                                                <input type="number" name="stockMax" id="estockMax" max="100000" min="0"
                                                       style="text-align: center; width: 70px">
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right"><span class="text-danger">* </span>商品尺码：</td>
                                    <td colspan="3">
                                        <div class=" validate_input">
                                            <input type="text" maxlength="30" name="barCode" placeholder="商品条码..."
                                                   id="ebarCode">
                                            <div class="error_container">
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right">商品分类：</td>
                                    <td>
                                        <input type="text" name="classify" placeholder="商品分类..." id="eclassify">
                                    </td>
                                    <td class="td_right">商品品牌：</td>
                                    <td>
                                        <div style="display:flex;width:180px;">
                                            <input type="text" name="brand" placeholder="商品品牌..." id="ebrand">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right">款式：</td>
                                    <td><input type="text" name="style" id="estyle"></td>
                                    <td class="td_right">商品材质：</td>
                                    <td><select name="material" id="ematerial">
                                        <option value="">请选择...</option>
                                        <option value="854">尼龙</option>
                                        <option value="722">涤绢混纺</option>
                                        <option value="723">涤粘华达呢</option>
                                        <option value="709">麻棉混纺</option>
                                        <option value="710">涤麻混纺</option>
                                        <option value="711">进口长绒棉</option>
                                        <option value="712">绢丝</option>
                                        <option value="713">真丝</option>
                                        <option value="714">天丝</option>
                                        <option value="715">丝光棉纱线</option>
                                        <option value="717">竹纤维</option>
                                        <option value="718">睛纶</option>
                                        <option value="719">丝光羊毛</option>
                                        <option value="720">100%美丽诺超细羊毛</option>
                                        <option value="721">涤棉混纺</option>
                                        <option value="697">维纶</option>
                                        <option value="698">纯麻细纺</option>
                                        <option value="699">夏布</option>
                                        <option value="700">交织麻织物</option>
                                        <option value="703">啥味呢</option>
                                        <option value="704">麦尔登</option>
                                        <option value="705">长毛绒</option>
                                        <option value="706">卡其</option>
                                        <option value="707">山羊绒</option>
                                        <option value="708">马海毛</option>
                                        <option value="685">皮革</option>
                                        <option value="686">化纤</option>
                                        <option value="687">混纺</option>
                                        <option value="688">丝光棉</option>
                                        <option value="689">雪纺</option>
                                        <option value="690">桑蚕丝</option>
                                        <option value="691">粘胶</option>
                                        <option value="692">醋酯纤维</option>
                                        <option value="693">涤纶</option>
                                        <option value="694">锦纶</option>
                                        <option value="695">丙纶</option>
                                        <option value="696">氨纶</option>
                                        <option value="681">棉布</option>
                                        <option value="682">麻布</option>
                                        <option value="683">丝绸</option>
                                        <option value="684">呢绒</option>
                                    </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right">性别：</td>
                                    <td>
                                        <select name="gender" id="egender">
                                            <option value="1">通款</option>
                                            <option value="2">男</option>
                                            <option value="3">女</option>
                                        </select>
                                    </td>
                                    <td class="td_right">单位：</td>
                                    <td><select name="unit" id="eunit">
                                        <option value="">请选择...</option>
                                        <option value="11">
                                            袋
                                        </option>
                                        <option value="12">
                                            双
                                        </option>
                                        <option value="13" selected="selected">
                                            条
                                        </option>
                                        <option value="14">
                                            套
                                        </option>
                                        <option value="15">
                                            箱
                                        </option>
                                        <option value="16">
                                            副
                                        </option>
                                        <option value="17">
                                            件
                                        </option>
                                        <option value="18">
                                            支
                                        </option>
                                        <option value="19">
                                            盒
                                        </option>
                                        <option value="20">
                                            瓶
                                        </option>
                                        <option value="21">
                                            片
                                        </option>
                                        <option value="22">
                                            码
                                        </option>
                                        <option value="23">
                                            个
                                        </option>
                                        <option value="24">
                                            手
                                        </option>
                                        <option value="25">
                                            米
                                        </option>
                                        <option value="26">
                                            只
                                        </option>
                                    </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right">季节：</td>
                                    <td class="form-inline">
                                        <select name="season" id="eseason">
                                            <option value="">请选择...</option>
                                            <option value="133">
                                                春秋
                                            </option>
                                            <option value="112">
                                                春季
                                            </option>
                                            <option value="113">
                                                夏季
                                            </option>
                                            <option value="114">
                                                秋季
                                            </option>
                                            <option value="115">
                                                秋冬
                                            </option>
                                            <option value="116">
                                                冬季
                                            </option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right">备注：</td>
                                    <td colspan="2">
                                        <input type="text" maxlength="80" name="remark" placeholder="备注..."
                                               id="eremark">
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_right"><span class="text-danger">* </span>排序：</td>
                                    <td>
                                        <div class="validate_input">
                                            <input required="" type="number" name="sort" id="esort" max="1000000"
                                                   min="0" style="text-align: center; width: 100px">
                                        </div>
                                    </td>
                                    <td class="td_right">状态：</td>
                                    <td>
                                        <select name="status" id="estatus">
                                            <option value="1">是</option>
                                            <option value="0">否</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="col-xs-6" style="margin: 50px">
                                        <button onclick="editGoods()">确定</button>
                                    </td>
                                    <td class="col-xs-6" style="margin: 0 auto">
                                        <button onclick="hideShadow()">取消</button>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
            </div>

            <!--弹出层时背景层DIV-->
            <div id="fade" class="black_overlay"></div>
            <!--弹出层时背景层DIV-->
            <div id="MyDiv" class="white_content" style="left: 50px;width:80%;top:100px" >
                <div style=" cursor: default; height: 25px; background: #0b97c4;">
                    <b style="float: left">新增商品</b><b style="float: right" onclick="CloseDiv('MyDiv','fade')">关闭</b>
                </div>

                <ul class="nav nav-tabs" role="tablist">
                    <li class="active">
                        <a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">通用信息</a>
                    </li>
                    <li class="">
                        <a href="#single" role="tab" id="single-tab" data-toggle="tab" data-link="single">单品条码</a>
                    </li>
                    <li class="">
                        <a href="#description" role="tab" id="description-tab" data-toggle="tab"
                           data-link="description">详细描述</a>
                    </li>
                    <li class="">
                        <a href="#album" role="tab" id="album-tab" data-toggle="tab" data-link="album">商品相册</a>
                    </li>
                </ul>
                <div class="tab-nav-indicator" style="left: 0px; right: 696.328px;"></div>
                <div class="tab-content">
                    <div class="tab-pane active in" id="info">
                        <table class="table table-condensed post_table ">
                            <tbody>
                            <tr>
                                <td><span class="text-danger">* </span>商品名称：</td>
                                <td>
                                    <input type="text" maxlength="30" name="name" placeholder="商品名称..." id="name"
                                           required>
                                </td>
                                <td>
                                    <nobr><span class="text-danger">* </span>商品货号：</nobr>
                                </td>
                                <td>
                                    <div class="validate_input">
                                        <input type="text"
                                               onkeypress="return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )"
                                               id="goodsSn" maxlength="128" value="0000000" placeholder="商品货号..."
                                               required>
                                    </div>
                                </td>

                            </tr>
                            <tr>
                                <td class="td_right"><span class="text-danger">* </span>采购价：</td>
                                <td>
                                <span class=" validate_input combo">
                                    <input type="text" class="combo combo-text" name="purchasePrice" onkeyup="num(this)"
                                           value="0.00" id="purchasePrice">
                                <span><span style="width:50px;">￥</span></span></span>
                                </td>
                                <td class="td_right"><span class="text-danger">* </span>批发价：</td>
                                <td>
                                <span class="validate_input combo">
                                    <input type="text" class="combo combo-text" name="wholesalePrice"
                                           onkeyup="num(this)" id="wholesalePrice" value="0.00">
                                <span><span style="width:50px;">￥</span></span></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">建议零售价：</td>
                                <td>
                                <span class="validate_input combo">
                                    <input type="text" class="combo combo-text" name="recommendPrice"
                                           onkeyup="num(this)" id="recommendPrice" value="0.00">
                                <span><span style="width:50px;">￥</span></span></span>
                                </td>
                                <td class="td_right"><span class="text-danger">* </span>零售价：</td>
                                <td>
                                <span class="validate_input combo" style="display:inline-block;">
                                    <input type="text" class="combo combo-text" name="salePrice" onkeyup="num(this)"
                                           id="salePrice" value="0.00">
                                 <span><span style="width:50px;">￥</span></span></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right"><span class="text-danger">* </span>商品颜色：</td>
                                <td colspan="3">
                                    <div class="box box-default collapsed-box">
                                        <div class="box-header with-border">
                                            <div class="box-title" id="all_color">全部选择<a href="./color_management"
                                                                                         style="float: right"
                                                                                         target="_blank">[添加]</a></div>
                                            <div class="box-tools pull-right">
                                                <button class="btn btn-box-tool" data-widget="collapse">
                                                    <i class="fa fa-plus"></i>
                                                </button>
                                            </div><!-- /.box-tools -->
                                        </div>
                                        <div class="box-body">
                                            <table class="table table-condensed">
                                                <tbody>
                                                <tr th:each="groups: ${groups}">
                                                    <td nowrap="nowrap" th:text="${groups}"></td>
                                                    <td>
                                                        <div th:each="goodsColors: ${goodsColors}">
                                                            <div class="col-sm-3 form-group"
                                                                 th:if="${groups} eq ${goodsColors.group}">
                                                                <nobr>
                                                                    <input type="checkbox" name="color"
                                                                           onclick="click_single()" id="goodsColors"
                                                                           th:value="${goodsColors}"
                                                                           th:text="${goodsColors.name}">
                                                                </nobr>
                                                            </div>
                                                        </div>
                                                    </td>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right"><span class="text-danger">* </span>商品尺码：</td>
                                <td colspan="3">
                                    <div class=" validate_input">
                                        <div class="box box-default collapsed-box">
                                            <div class="box-header with-border">
                                                <div class="box-title" id="all_size">全部选择<a href="./size_management"
                                                                                            style="float: right"
                                                                                            target="_blank">[添加]</a>
                                                </div>
                                                <div class="box-tools pull-right">
                                                    <button class="btn btn-box-tool" data-widget="collapse">
                                                        <i class="fa fa-plus"></i>
                                                    </button>
                                                </div><!-- /.box-tools -->
                                            </div>
                                            <div class="box-body">
                                                <table class="table table-condensed">
                                                    <tbody>
                                                    <tr th:each="size_groups: ${size_groups}">
                                                        <td nowrap="nowrap" th:text="${size_groups}"></td>
                                                        <td>
                                                            <div th:each="goodsSizes: ${goodsSizes}">
                                                                <div class="col-sm-3 form-group"
                                                                     th:if="${size_groups} eq ${goodsSizes.group}">
                                                                    <nobr>
                                                                        <input type="checkbox" name="size"
                                                                               onclick="click_single()" id="goodsSize"
                                                                               th:value="${goodsSizes}"
                                                                               th:text="${goodsSizes.name}">
                                                                    </nobr>
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">包装数：</td>
                                <td>
                                    <div class="validate_input ">
                                        <input style="width: 64px; " type="number" min="1" max="100" name="backingPag"
                                               onkeypress="return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )"
                                               value="2" id="backingPag" required>
                                    </div>
                                </td>
                                <td>
                                    <a href="../setting/system_parameters" target="_blank">库存预警:</a>
                                </td>
                                <td>
                                    <div style="float:left;display:inline;">
                                        <div class="validate_input" style="display:inline;">上限:
                                            <input type="number" name="stockMin" id="stockMin" max="100000"
                                                   onkeypress="return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )"
                                                   min="0" value="50" style="text-align: center; width: 70px">
                                        </div>
                                    </div>
                                    <div style="float:right;display:inline;">
                                        <div class="validate_input" style="display:inline;">下限:
                                            <input type="number" name="stockMax" id="stockMax" max="100000"
                                                   onkeypress="return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )"
                                                   min="0" value="2000" style="text-align: center; width: 70px">
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">商品条码：</td>
                                <td>
                                    <input type="text" maxlength="30" name="barCode"
                                           onkeypress="return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )"
                                           placeholder="商品条码..." id="barCode">
                                </td>
                                <td class="td_right">起订量：</td>
                                <td>
                                    <div class="validate_input ">
                                        <input style="width: 64px; " type="number" min="1" max="10000"
                                               onkeypress="return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )"
                                               name="backingPag" value="2" id="start" required>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">商品分类：</td>
                                <td>
                                    <input type="text" name="classify" placeholder="商品分类..." id="classify">

                                </td>
                                <td class="td_right">商品品牌：</td>
                                <td>
                                    <select class="form-control select2" style="width: 60%;" id="goodsBrands">
                                        <option style='display: none' value=null text="请选择..."></option>
                                        <option th:each="option:${goodsBrands}" th:text="${option.name}"
                                                th:value="${option.id}"></option>
                                    </select>
                                    <a href="./brand_management" style="float: right" target="_blank">[添加]</a>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">款式：</td>
                                <td><input type="text" name="style" id="style"></td>
                                <td class="td_right">商品材质：</td>
                                <td><select class="form-control" name="material" id="material">
                                    <option value=null>请选择...</option>
                                    <option th:each="goodsMaterials:${goodsMaterials}" th:text="${goodsMaterials.name}"
                                            th:value="${goodsMaterials.id}"></option>
                                </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">性别：</td>
                                <td>
                                    <div id="gender">
                                        <label class="form-inline sel-a"><input type="radio" checked="checked" value="1"
                                                                                name="gender">
                                            通款 &nbsp;</label>
                                        <label class="form-inline sel-a"><input type="radio" value="2" name="gender"> 男款
                                            &nbsp;</label>
                                        <label class="form-inline sel-a"><input type="radio" value="3" name="gender"> 女款
                                            &nbsp;</label>
                                    </div>
                                </td>
                                <td class="td_right">单位：</td>
                                <td><select class="form-control" name="unit" id="unit">
                                    <option th:each="goodsUnits:${goodsUnits}" th:text="${goodsUnits.name}"
                                            th:value="${goodsUnits.id}"></option>
                                </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">季节：</td>
                                <td class="form-inline">
                                    <select class="form-control" name="season" id="season">
                                        <option value=null>请选择...</option>
                                        <option th:each="goodsSeasons:${goodsSeasons}" th:text="${goodsSeasons.name}"
                                                th:value="${goodsSeasons.id}"></option>
                                    </select>
                                </td>
                                <td>年份：</td>
                                <td>
                                    <input id="meeting" type="date"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">备注：</td>
                                <td colspan="3">
                                    <input type="text" style="width: 500px;" maxlength="80" name="remark"
                                           placeholder="备注..." id="remark">
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right"><span class="text-danger">* </span>排序：</td>
                                <td>
                                    <div class="validate_input">
                                        <input value="100" required type="number" name="sort" id="sort" max="1000000"
                                               min="0" style="text-align: center; width: 100px">
                                    </div>
                                </td>
                                <td class="td_right">状态：</td>
                                <td id="status">
                                    <label class=" sel-a"><input type="radio" name="status" value="1" checked="checked">启用&nbsp;</label>
                                    <label class=" sel-a"><input type="radio" name="status" value="2">停用&nbsp;</label>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="tab-pane" id="description">
                        <form>
                            <textarea id="editor1" name="editor1" rows="10" cols="80">
                                This is my textarea to be replaced with CKEditor.
                            </textarea>
                        </form>
                    </div>
                    <div class="tab-pane" id="single">
                        <div class="modal-body">
                            <table id="twoDisTable" class="table table-bordered table-condensed" cellspacing="0"
                                   width="100%">
                                <thead>
                                <tr id="mTh">
                                    <th></th>
                                </tr>
                                </thead>
                                <tbody id="myBody">
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="tab-pane" id="album">
                        <div class="allimg">
                            <div class="col-xs-2">
                                <ul class="nav nav-tabs" role="tablist">
                                    <li class="active "><a href="#load" role="tab" id="load-tab" data-toggle="tab"
                                                           data-link="load">本地上传</a></li>
                                    <li class=""><a href="#history" role="tab" id="history-tab" data-toggle="tab"
                                                    data-link="history">历史图库</a></li>
                                </ul>
                            </div>
                            <div class="col-xs-10 tab-content">
                                <div class="tab-pane active in" id="load">
                                    <table>
                                        <tr>
                                            <td>
                                                    <span class="btn-normal">
                                                        <input id="local-img" type="file"
                                                               accept="image/jpeg,image/jpg,image/png" multiple="">
                                                    </span>
                                            </td>
                                            <td>
                                                本地图片...
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <input type="text" style="text-align: center; width: 170px"
                                                       class="form-control" placeholder="输入网络图片链接...">
                                            </td>
                                            <td>
                                                <button class="btn-normal" type="button" id="remoteImgBtn">
                                                    <span>预览</span>
                                                </button>
                                            </td>
                                        </tr>
                                    </table>
                                    <br>
                                    <div>提示：本地上传图片大小不能超过4M，一个商品最多可添加 9 张图片。</div>

                                </div>
                                <div class="tab-pane" id="history">
                                    <div>
                                        <div>提示：点击添加到相册中，最多可以添加 9 张。</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div style="margin: 50px;float: right">
                    <nobr>
                        <button onclick="CloseDiv('MyDiv','fade')">取消</button>
                    </nobr>
                </div>
                <div style="margin: 50px;float: right">
                    <nobr>
                        <button th:onclick="addGoods()">确定</button>
                    </nobr>
                </div>
            </div>


        </section>
        <!-- /.content -->
    </div>
    <footer th:replace="common/footer::common_footer"></footer>
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Create the tabs -->
        <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
            <li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
            <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
            <!-- Home tab content -->
            <div class="tab-pane" id="control-sidebar-home-tab">
                <h3 class="control-sidebar-heading">Recent Activity</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-birthday-cake bg-red"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Langdon's Birthday</h4>

                                <p>Will be 23 on April 24th</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-user bg-yellow"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>

                                <p>New phone +1(800)555-1234</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-envelope-o bg-light-blue"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>

                                <p>nora@example.com</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-file-code-o bg-green"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>

                                <p>Execution time 5 seconds</p>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

                <h3 class="control-sidebar-heading">Tasks Progress</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Custom Template Design
                                <span class="label label-danger pull-right">70%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-danger" style="width: 70%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Update Resume
                                <span class="label label-success pull-right">95%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-success" style="width: 95%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Laravel Integration
                                <span class="label label-warning pull-right">50%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-warning" style="width: 50%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Back End Framework
                                <span class="label label-primary pull-right">68%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-primary" style="width: 68%"></div>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

            </div>
            <!-- /.tab-pane -->
            <!-- Stats tab content -->
            <div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
            <!-- /.tab-pane -->
            <!-- Settings tab content -->
            <div class="tab-pane" id="control-sidebar-settings-tab">
                <form method="post">
                    <h3 class="control-sidebar-heading">General Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Report panel usage
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Some information about this general settings option
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Allow mail redirect
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Other sets of options are available
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Expose author name in posts
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Allow the user to show his name in blog posts
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <h3 class="control-sidebar-heading">Chat Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Show me as online
                            <input type="checkbox" class="pull-right" checked>
                        </label>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Turn off notifications
                            <input type="checkbox" class="pull-right">
                        </label>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Delete chat history
                            <a href="javascript:void(0)" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
                        </label>
                    </div>
                    <!-- /.form-group -->
                </form>
            </div>
            <!-- /.tab-pane -->
        </div>
    </aside>
    <div class="control-sidebar-bg"></div>
</div>
<!-- jQuery 3 -->
<script src="../../bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="../../bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="../../bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="../../bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="../../bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>
<!-- page script -->
<script src="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.2/dist/extensions/fixed-columns/bootstrap-table-fixed-columns.js"></script>
<!-- CK Editor -->
<script src="../../bower_components/ckeditor/ckeditor.js"></script>
<!-- Select2 -->
<script src="../../bower_components/select2/dist/js/select2.full.min.js"></script>
<script th:inline="javascript">
    var barcode = [[${barcode}]];
    $(function () {
        CKEDITOR.replace('editor1')
        $('#example1').DataTable()
    })


    $(function () {
        //Initialize Select2 Elements
        $('.select2').select2()

        $("#all_color").click(function () {
            var checkboxs = document.getElementsByName('color');
            for (var i = 0; i < checkboxs.length; i++) {
                checkboxs[i].checked = true;
            }
            click_single()
        })

        $("#all_size").click(function () {
            var checkboxs = document.getElementsByName('size');
            for (var i = 0; i < checkboxs.length; i++) {
                checkboxs[i].checked = true;
            }
            click_single()
        })
    })

    //商品对应尺寸
    var currentSizes = [];
    //商品对应颜色
    var currentColors = [];
    //二维输入表格
    var twoDisTable;

    if (barcode.product_barcode_later != 10000) {
        var _max = barcode.product_barcode_later.substring(0, 4);
        var code = barcode.product_barcode_forward.toString() + PrefixInteger(_max, 4).toString();
        code = code + CheckBarCode(code);
        $("#barCode").val(code)
    }

    // 添加
    function addGoods() {
        var goods = new Array();
        var temp = 0;
        var data = twoDisTable.$("input").toArray();
        for (i = 0; i < data.length; i++)
            for (j = i + 1; j < data.length; j++) {
                var it = data[i].value;
                if (data[i].value == data[j].value) {
                    alert("单品条码重复:" + data[i].value + ";")
                    return;
                }
            }
        for (i = 0; i < currentColors.length; i++) {
            var color = currentColors[i];
            color = color.replace("=", ",");
            color = color.split(",")
            for (j = 0; j < currentSizes.length; j++) {
                var size = currentSizes[j];
                size = size.replace("=", ",");
                size = size.split(",");
                var good = {
                    size: size[1],
                    color: color[1],
                    onlyBarCode: data[temp].value,
                    barCode: $("#barCode").val(),
                    name: $("#name").val(),
                    goodsNumber: $("#goodsSn").val(),
                    //imgUrl:$("#").val(),
                    purchasePrice: $("#purchasePrice").val(),
                    wholesalePrice: $("#wholesalePrice").val(),
                    salePrice: $("#salePrice").val(),
                    recommendPrice: $("#recommendPrice").val(),
                    gender: $("input[name='gender']:checked").val(),
                    classify: $("#classify").val(),
                    brand: $("#goodsBrands").val(),
                    material: $("#material").val(),
                    season: $("#season").val(),
                    style: $("#style").val(),
                    unit: $("#unit").val(),
                    backingPag: $("#backingPag").val(),
                    stockMin: $("#stockMin").val(),
                    stockMax: $("#stockMax").val(),
                    remark: $("#remark").val(),
                    sort: $("#sort").val(),
                    status: $("input[name='status']:checked").val(),
                };
                temp++;
                goods.push(good);
            }
        }
        var test = JSON.stringify(goods);
        $.ajax({
            url: "/goods/addGoods",
            type: "POST",
            data: {
                'goods': test,
            },
            success: function (data) {
                if (data.code == 1) {
                    window.location.href = "/setting/commodity_management";
                    alert("增加完成");
                } else {
                    alert(data.msg);
                }
            }
        })
    }


    /**
     * 处理并显示二维录入框
     */
    var len_max = barcode.single_barCode_later;

    function click_single() {
        if (twoDisTable != null) {
            //重置
            twoDisTable.destroy();
            twoDisTable = null;
            $("#mTh th").remove();
            $("#mTh").append("<th></th>")
            $("#myBody tr").remove();
        }
        var check_color = new Array();
        $("input[name='color']:checked").each(function (i) {
            check_color[i] = $(this).val();
        });
        var len_color = $("input[name='color']:checked").length;
        var check_size = new Array();
        $("input[name='size']:checked").each(function (i) {
            check_size[i] = $(this).val();
        });
        var len_color = $("input[name='size']:checked").length;
        currentSizes = check_size;
        currentColors = check_color;
        if (currentColors.length * currentSizes.length <= (10000 - len_max)) {
            var sizeThTemp = "";
            var colorBodyTemp = "";
            //构建颜色
            var weishu = 0;
            $.each(currentColors, function (index, value) {
                value = value.split("\'");
                colorBodyTemp += "<tr><td>" + value[1] + "</td>";
                for (i = 0; i < currentSizes.length; i++) {
                    //使用中间量 使字符串对象可以有特殊符号如""
                    var code = barcode.single_barCode_forward.toString() + PrefixInteger(len_max - weishu, 4).toString();
                    code = code + CheckBarCode(code);
                    var temp = "<td><input type=\"text\" value=\"" +
                        code +
                        "\" onkeypress=\"return( /[\\d]/.test(String.fromCharCode(event.keyCode) ) )\" style=\"width:100%\" align=\"right\" min='1'></td>";
                    colorBodyTemp += temp;
                    weishu = weishu - 1;
                }
                colorBodyTemp += "</tr>";
            });
            //构建尺码
            $.each(currentSizes, function (index, value) {
                value = value.split("\'");
                var temp = "<th class=\"text-center\">" + value[1] + "</th>";
                sizeThTemp += temp
            });
            $("#myBody").append(colorBodyTemp);
            $("#mTh").append(sizeThTemp);
            //二维输入表格 在Ajax 结束前重置表格
            twoDisTable = $('#twoDisTable').DataTable({
                searching: false,
                bLengthChange: false,
                paging: false,
                ordering: false
            });
        }
        else {
            alert("自动生成单品条码失败，请到条码管理配置新的厂商识别码！");
        }
    }

    // 数字0补齐
    function PrefixInteger(num, length) {
        return (Array(length).join('0') + num).slice(-length);
    }

    // ean-13 获取最后一位
    function CheckBarCode(s) {
        var a = 0;
        var b = 0;
        var c = 0;
        var d = 0;
        var e = 0;
        for (var i = 1; i <= 12; i++) {
            var sc = parseInt(s[i - 1]);
            if (i <= 12 && i % 2 == 0) {
                a += sc;
            }
            else if (i <= 11 && i % 2 == 1) {
                b += sc;
            }
        }
        c = a * 3;
        d = b + c;
        if (d % 10 == 0)
            e = d - d;
        else
            e = d + (10 - d % 10) - d;
        return e;

    }

    // 删除商品
    function deleteGoods(goodsName) {
        $(document).ready(function () {

            $("#btn").click(function () {
                var ck = $("input[type='checkbox']:checked")    //获取选中的复选框数组

                var ckVal = "";
                for (var i = 0; i < ck.length; i++) {

                    //alert($(ck[i]).val())//循环得到当前选择的值

                    ckVal += $(ck[i]).val() + ",";
                }
            });

        });
        $.ajax({
            url: "/goods/deleteGoods",
            type: 'POST',
            data: {
                goodsName: goodsName
            },
            success: function (data) {
                if (data.code == 1) {
                    window.location.href = "/setting/commodity_management";
                    alert("删除成功");
                } else {
                    alert(data.msg);
                }
            }
        })
    }

    // 打开编辑单位框
    var eid;
    var eimgUrl;

    function editGoodsDiv(id, name, sort) {
        if (name == null) {
            alert("未知错误");
            return 0;
        }
        eid = id;
        $("#ename").val(name);
        $("#esort").val(sort);
        $(".shadow").css({'display': 'block'});
        $("#editGoods").show();
        return 0;
    }

    // 修改分组
    function editGoods() {
        $.ajax({
            url: "/goods/editGoods",
            type: 'POST',
            data: {
                id: eid,
                imgUrl: eimgUrl,
                name: $("#ename").val(),
                goodsNumber: $("#egoodsNumber").val(),
                barCode: $("#ebarCode").val(),
                purchasePrice: $("#epurchasePrice").val(),
                wholesalePrice: $("#ewholesalePrice").val(),
                salePrice: $("#esalePrice").val(),
                recommendPrice: $("#erecommendPrice").val(),
                color: $("#ecolor").val(),
                size: $("#esize").val(),
                classify: $("#eclassify").val(),
                brand: $("#ebrand").val(),
                material: $("#ematerial").val(),
                season: $("#eseason").val(),
                style: $("#estyle").val(),
                unit: $("#eunit").val(),
                backingPag: $("#ebackingPag").val(),
                stockMin: $("#estockMin").val(),
                stockMax: $("#estockMax").val(),
                gender: $("#egender").val(),
                remark: $("#eremark").val(),
                sort: $("#esort").val(),
                status: $("#estatus").val()
            },
            success: function (data) {
                if (data.code == 1) {
                    window.location.href = "/setting/commodity_management";
                    alert("修改成功");
                } else {
                    alert(data.msg);
                }
            }
        })
    }

    function searchForName() {
        var goodsName = $("#findGoods").val();
        window.location.href = "/setting/commodity_management?goodsName=" + goodsName;
    }

    function hideShadow() {
        $(".shadow").css({'display': 'none'});
        $('#addGoods').hide();
        $('#editGoods').hide();
        $("#goods")[0].reset();
    }

    //分离pc与移动
    function IsPC() {
        var userAgentInfo = navigator.userAgent;//获取当前浏览器的信息
        var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];

        var flag = true;
        for (var i = 0; i < Agents.length; i++) {
            if (userAgentInfo.indexOf(Agents[i]) > 0) {//判断是否是移动端
                flag = false;
                break;
            }
        }
        return flag;
    }

    $(document).ready(function () {
        if (IsPC()) {
            $("#pcPage").show();//pc端页面显示
        } else {
            $("#mobile").show();
            $("#editGoods").css({"width": "80%"});
            $("#editGoods").css({"left": "10%"});
            $("#editGoods").css({"top": "110px"});//移动端页面显示
        }
    })
    //冻结列
    var $table = $('#example2')

    function buildTable($el) {

        var data = []

        $el.bootstrapTable('destroy').bootstrapTable({
            data: data,
            search: true,
            toolbar: '.toolbar',
            fixedColumns: true,
            fixedNumber: +$('#fixedNumber').val()
        })
    }

    $(function () {
        buildTable($table)

        $('#fixedNumber').change(function () {
            buildTable($table)
        })
    })

    //限制input输入保留两位小数
    function num(obj, val) {
        obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
        obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
        obj.value = obj.value.replace(/\.{2,}/g, ""); //只保留第一个, 清除多余的
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
    }
</script>
</body>
</html>
